#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexDotNumber(L"(\\d+\\.\\d+)(\\.\\d+)+");

void TextNormalizer::TnReDotNumber(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while(regex_search(*fpInWsentence, tWsmatch, mcWregexDotNumber))
	{
		string tInSentence = wstring2utf8string(*fpInWsentence);
		string tStrMatch = wstring2utf8string(tWsmatch[0]);	//匹配到数点数点数组合的字符串

		string tStrReplace = "";
		vector<string> tVecItems = StrSplit(tStrMatch, ".");
		for(size_t i=0; i<tVecItems.size(); i++) {
			if(tVecItems[i] != "") {
				if(i>0) {
					tStrReplace += (fcInLanguage==LANG_EN) ? " dot " : "点";
				}
				tStrReplace += ReplaceMethod(vector<string>{tVecItems[i]}, (fcInLanguage==LANG_EN)?RME_en_telephone:RME_zh_telephone);
			}
		}

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
